<template>
  <v-row>
    <div class="col-xs-12 col-sm-12 col-md-9 col-lg-9 col-xl-9">
      <router-view></router-view>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3 col-xl-3 tab">
      <router-link v-for="(menu, index) in menuList" :key="index" :to="{path: menu.path}">
        <div :class="{'tab-item': true, 'tab-item-active': $route.path === menu.path}">{{menu.title}}</div>
      </router-link>
    </div>
  </v-row>
</template>

<script lang="ts">
import { Component, Vue} from 'vue-property-decorator';

@Component
export default class Stock extends Vue {
  protected menuList: TypeFrontStock.StockMenuItem[] = [];
  protected async getStockConfig(): Promise<void> {
    const { data } = await this.$api.front.stockConfig<TypeFrontStock.StockConfig>();
    this.menuList = data.menus;
  }
  protected created(): void {
    this.getStockConfig();
  }
}
</script>

<style lang="scss" scoped>
  .tab {
    a {
      color: $fontColor;
    }
    &-item {
      position: relative;
      cursor: pointer;
      height: 48px;
      line-height: 48px;
      padding-left: $padding;
      padding-right: $padding;
      &::before {
        content: '';
        display: block;
        width: 2px;
        background: $primary;
        position: absolute;
        top: 50%;
        bottom: 50%;
        left: 0;
      }
      &:hover {
        &::before {
          top: 0;
          bottom: 0;
          transition: all .5s ease 0s;
        }
      }
      &-active {
        color: $primary;
        &::before {
          content: '';
          display: block;
          width: 2px;
          background: $primary;
          position: absolute;
          top: 0;
          bottom: 0;
          left: 0;
        }
      }
    }
  }
  // 大屏幕
  @media (min-width: 960px) {
    .content-body {
      box-shadow: 5px 0px 5px -5px rgba(0,0,0,.2);
      padding: 12px;
    }
    .vertical-nav {
      padding: 12px;
    }
  }
  // 中等屏幕
  @media (min-width: 600px) and (max-width: 960px) {
    .content-body {
      padding: 12px;
      box-shadow: 0px 5px 5px -5px rgba(0,0,0,.2);
    }
    .vertical-nav {
      padding: 12px;
    }
  }
  // 小屏幕
  @media (max-width: 600px) {
    .content-body {
      padding: 12px;
      box-shadow: 0px 5px 5px -5px rgba(0,0,0,.2);
    }
    .vertical-nav {
      padding: 12px;
    }
  }
</style>
